#include "mainwindow.h"
#include "./ui_mainwindow.h"

#include <QPushButton>
#include <QThread>

#include "MyThread.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    m_thread = new MyThread();

    connect(ui->pushButton, &QPushButton::clicked, this, &MainWindow::OnBtnClicked);
}

MainWindow::~MainWindow()
{
    delete ui;

    m_thread->terminate();
    m_thread->deleteLater();
    //delete m_thread;
}

void MainWindow::OnBtnClicked()
{
    qDebug() << "MainWindow::OnBtnClicked: " << QThread::currentThreadId();
    m_thread->start();
}
